package com.hwd.gmall.cart.controller;

import com.hwd.gmall.cart.service.CartInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 购物车管理模块的控制层
 *
 * @author 黄伟东/Victor
 * @date 2022/5/5 23:33
 */
@RestController
@RequestMapping(value = "/api/cart")
public class CartInfoForOrder {

    @Resource
    private CartInfoService cartInfoService;

    /**
     * 查询当前用户订单确认页的购物车数据
     *
     * @return java.util.Map<java.lang.String, java.lang.Object>
     */
    @GetMapping(value = "/getOrderConfirmedCartInfo")
    public Map<String, Object> getOrderConfirmedCartInfo() {
        return cartInfoService.listConfirmedCartInfo();
    }

    /**
     * 新增购物车后，清空购物车
     *
     * @return java.lang.Boolean
     */
    @GetMapping(value = "/removeCartInfoAfterAddCartInfo")
    public Boolean removeCartInfoAfterAddCartInfo() {
        return cartInfoService.removeCartInfoAfterAddCartInfo();
    }
}
